import request from '@/utils/request'
import cloudConstant from "@/utils/cloudConstant";
const api_name = cloudConstant.SYSTEM_ROLES;
export default {
  /**获取分页列表数据*/
  getPageList(page:number, limit:number, searchObj:object) {
    return request({
      url: `${api_name}/getRolePageList/${page}/${limit}`,
      method: 'get',
      params: searchObj // url查询字符串或表单键值对
    })
  },
  /**获取角色*/
  getById(id:any) {
    return request({
      url: `${api_name}/getRoleById/${id}`,
      method: 'get'
    })
  },
  /**保存角色*/
  addRole(role:object) {
    return request({
      url: `${api_name}/addRoles`,
      method: 'post',
      data: role,
    })
  },
  /**更新角色*/
  updateById(role:object,ids : Array<string>) {
    return request({
      url: `${api_name}/updateRole`,
      method: 'post',
      data: {role,ids}
    })
  },
  /**删除角色*/
  removeById(id:number){
    return request({
      url: `${api_name}/removeRole/${id}`,
      method: 'post'
    })
  },
  /**批量删除*/
  removeRows(idList:Array<number>){
    return request({
      url: `${api_name}/batchRemoveRole`,
      method: 'post',
      data:idList
    })
  },
  /**根据角色分配权限*/
  doAssignRoleAuth(roleId:number, menu:number) {
    return request({
      url: `${api_name}/doAssignRoleAuth`,
      method: "post",
      params: {roleId, menu},
    })
  },
  getAllRoles(){
    return request({
      url:`${api_name}/getAllRoles`,
      method:'get'
    })
  }
}
